![]() |
CopyMask |
||||
Header: | Quickdraw.h | Carbon status: | Supported | |
Copies a bit or pixel image from one graphics port or offscreen graphics world into another graphics port only where the bits in a mask are set to 1.
void CopyMask ( const BitMap *srcBits, const BitMap *maskBits, const BitMap *dstBits, const Rect *srcRect, const Rect *maskRect, const Rect *dstRect );
The source BitMap structure.
The mask BitMap structure.
The destination BitMap structure.
The source rectangle.
The mask rectangle. This must be the same size as the rectangle passed in the srcRect parameter. The rectangle you pass in this parameter selects the portion of the bitmap or pixel map that you specify in the maskBits parameter to use as the mask.
The destination rectangle.
The CopyMask function copies the source bitmap or pixel map that you specify in the srcBits parameter to a destination bitmap or pixel map that you specify in the dstBits parameter—but only where the bits of the mask bitmap or pixel map that you specify in the maskBits parameter are set to 1. When copying images between color graphics ports, you must coerce each CGrafPort structure to a GrafPort structure, dereference the portBits fields of each, and then pass these “bitmaps” in the srcBits and dstBits parameters. If your application copies a pixel image from a color graphics port called MyColorPort, for example, you could specify (*GrafPtr(MyColorPort)).portBits in the srcBits parameter.
Using the srcRect and dstRect parameters, you can specify identically or differently sized source and destination rectangles; for differently sized rectangles, CopyMask scales the source image to fit the destination. When you specify rectangles in the srcRect and dstRect parameters, use the local coordinate systems of, respectively, the source and destination graphics ports.
If you specify pixel maps to CopyMask, they may range from 1 to 32 pixels in depth. The pixel depth of the mask that you specify in the maskBits parameter is applied as a filter between the source and destination pixel maps that you specify in the srcBits and dstBits parameters. A black mask pixel value means that the copy operation is to take the source pixel; a white value means that the copy operation is to take the destination pixel. Intermediate values specify a weighted average, which is calculated on a color component basis. For each pixel’s color component value, the calculation is
(1 – mask) x source + (mask) x destination
Thus high mask values for a pixel’s color component reduce that component’s contribution from the source PixMap structure.
Use the bitmap returned by CalcMask as the mask in order to implement a mask copy similar to that performed by the MacPaint lasso tool. In the same way, you can use the pixel map returned by the CalcCMask function.
The CopyDeepMask function combines the functions of the CopyMask and CopyBits functions.
Calls to CopyMask are not recorded in pictures and do not print.
See the list of special considerations for CopyBits; these considerations also apply to CopyMask.
The CopyMask function may move or purge memory blocks in the application heap; do not call this function at interrupt time.
Supported in Carbon. Available in Carbon 1.0.2 and later when running Mac OS 8.1 or later.
© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)